package com.example.njupt.log;

import com.example.njupt.constant.LogConstants;

import timber.log.Timber;

/**
 * Author:      mwang
 * Create Date: Created in 2021/5/27 19:36
 * Update Date:
 * Modified By:
 * Description: Logger
 */
public class NjuptLogger {

    public static NjuptLogger instance = new NjuptLogger();

    public NjuptLogger() {
        if (isDebug()) {
            Timber.plant(new DebugTree());
        }
    }

    public void v(Object o) {
        Timber.tag(LogConstants.TAG).v(createLog(o));
    }

    public void d(Object o) {
        Timber.tag(LogConstants.TAG).d(createLog(o));
    }

    public void i(Object o) {
        Timber.tag(LogConstants.TAG).i(createLog(o));
    }

    public void w(Object o) {
        Timber.tag(LogConstants.TAG).w(createLog(o));
    }

    public void e(Object o) {
        Timber.tag(LogConstants.TAG).e(createLog(o));
    }

    public void json(String o) {
        Timber.tag(LogConstants.TAG).v(createJsonLog(o));
    }


    public void vTag(String tag, Object o) {
        Timber.tag(tag).v(createLog(o));
    }

    public void dTag(String tag, Object o) {
        Timber.tag(tag).d(createLog(o));
    }

    public void iTag(String tag, Object o) {
        Timber.tag(tag).i(createLog(o));
    }

    public void wTag(String tag, Object o) {
        Timber.tag(tag).w(createLog(o));
    }

    public void eTag(String tag, Object o) {
        Timber.tag(tag).e(createLog(o));
    }

    public void jsonTag(String tag, String o) {
        Timber.tag(tag).v(createJsonLog(o));
    }

    public boolean isDebug() {
        return true;
    }

    public String createLog(Object object) {
        return new LogHelper().create(object);
    }

    public String createJsonLog(String s) {
        return new LogHelper().createJson(s);
    }
}
